<?php
// author email: ugg.xchj@gmail.com
// 本代码仅供学习参考，不提供任何技术保证。
// 切勿使用本代码用于非法用处，违者后果自负。
// http://blog.csdn.net/zollty/article/details/7561052

include("Valite.php");

$valite = new valite();

// 这里的图片来源www.miibeian.gov.cn网站，
// 由于现在这段代码还不能实现自动对图片进行二值化
// 所以，如果你对其他图片进行验证，需要修改valite类中的
// getHec函数

// ok: 3qn5 55qn 2534
// bad: ee48
//$valite->bmp2jpeg("ydndw.bmp");
$valite->setImage("ee48.jpeg");
$valite->getHec();
$valite->filterInfo();
$valite->dealwithData();
//$valite->DrawDealData();
//$valite->Draw();
//echo "\n 结果是：";
$data = $valite->run();
echo implode("",$data);
echo "\n";

// // 这段代码用于添加验证码库，当你认为库不准确时，
   // 可以通过这种方式添加验证码库.
   // 字模库需要通过分析原始图片获取,可能每种类型的图形验证码字模库不一致.
$keyvalues = array(
'010101101101010'=>'0',
'010110010010111'=>'1',
'111001010100111'=>'2',
'111001111001111'=>'3',
'001011101111011'=>'4',
'111100111001111'=>'5',
'011100111101111'=>'6',
'111001010010100'=>'7',
'010101111101010'=>'8',
'111101111001110'=>'9',
'011001011101111'=>'a',
'100111101101111'=>'b',
'011100100100011'=>'c',
'001011101101011'=>'d',
'010101111100011'=>'e',
'010111010010010'=>'f',
'111101111011011'=>'g',
'100111101101101'=>'h',
'001001001001111'=>'j',
'101110110110101'=>'k',
'111101101101101'=>'n',
'111101111110100'=>'p',
'111101111001001'=>'q',
'111100010001111'=>'s',
'010111010010011'=>'t',
'111110110110110'=>'r',
'101101101101111'=>'u',
'101101111111010'=>'v',
'101111010111101'=>'x',
'101101010010100'=>'y',
'111111010110111'=>'z',
'011101101101011'=>'0',
'111101101101111'=>'0',
'110101101101111'=>'0',
'111101101101110'=>'0',
'110001010111111'=>'2',
'111001011001011'=>'3',
'011011111111010'=>'4',
'011011111111111'=>'4',
'011011111111011'=>'4',
'001011101111001'=>'4',
'111100111101110'=>'5',
'111100111001000'=>'5',
'100110101111001'=>'6',
'011100111101011'=>'6',
'010100111101110'=>'6',
'110001001010110'=>'7',
'110001001010100'=>'7',
'111001010000010'=>'7',
'111001010010010'=>'7',
'111101111101011'=>'8',
'011101111111110'=>'8',
'011101111111110'=>'8',
'111111111111110'=>'8',
'111101111001010'=>'9',
'011011011101110'=>'a',
'011011011111110'=>'a',
'011001011101110'=>'a',
'100111101111110'=>'b',
'100110101101111'=>'b',
'011110100111010'=>'c',
'011110100100110'=>'c',
'011110100110011'=>'c',
'011100100100011'=>'c',
'010110100110011'=>'c',
'011110100110110'=>'c',
'011111100100011'=>'c',
'011101101111110'=>'d',
'001011101101111'=>'d',
'001001111101111'=>'d',
'010111111110010'=>'e',
'111101111111010'=>'e',
'010111111110011'=>'e',
'011111010010010'=>'f',
'011011010010010'=>'f',
'100100111101101'=>'h',
'100111101101001'=>'h',
'001001001001011'=>'j',
'101100110111100'=>'k',
'100100110101101'=>'k',
'101101110101101'=>'k',
'100100110110101'=>'k',
'100100110101100'=>'k',
'100101110101101'=>'k',
'100100110111101'=>'k',
'100101110101100'=>'k',
'101100110111100'=>'k',
'001101101101100'=>'n',
'111111101101101'=>'n',
'111101101101001'=>'n',
'111101101101100'=>'n',
'011101101101100'=>'n',
'111101101111100'=>'p',
'111101111100100'=>'p',
'111101111011001'=>'q',
'111101101011001'=>'q',
'011101111111001'=>'q',
'111111110110110'=>'r',
'011110110110110'=>'r',
'111101110001011'=>'s',
'011100111001011'=>'s',
'011111010110011'=>'t',
'011111010010011'=>'t',
'011111010110011'=>'t',
'001101101101110'=>'u',
'100101101111001'=>'u',
'101111011011010'=>'v',
'001001111110010'=>'v',
'101101111111010'=>'v',
'101101111111010'=>'v',
'001101110111101'=>'x',
'100101011111101'=>'x',
'111111010111101'=>'x',
'001011010011111'=>'x',
'111110010111101'=>'x',
'101101010010110'=>'y',
'101111011010010'=>'y',
'001101111010010'=>'y',
'001101110010010'=>'y',
'001101110010000'=>'y',
'111111010110111'=>'z',
'111001010110011'=>'z',
'111001010110011'=>'z');

foreach($keyvalues as $key=>$value)
{
	$re = $valite->setKeyValue($key,$value);
	if($re != $value)
	{
		echo "===ERROR===\n";
		echo "key: ".$key."\n";
		echo "Value: ".$value."\n";
		echo "Old Value: ".$re."\n";
	}else{
//		echo "===OK===\n";
	}
}

?>
